import axios from 'axios';

let baseUrl=process.env.API_URL;

//一次封装
export const GET=(url,params)=>{
  axios.defaults.headers.common['authorization'] = 'Bearer '+localStorage.getItem('token')
  return axios.get(`${baseUrl}${url}`,{params:params}).then((data)=>{return data})
}

export const POST=(url,params)=>{
  axios.defaults.headers.common['authorization'] = 'Bearer '+localStorage.getItem('token')
  return axios.post(`${baseUrl}${url}`,params).then((data)=>data)
}

export const PUT=(url,params)=>{
  axios.defaults.headers.common['authorization'] = 'Bearer '+localStorage.getItem('token')
  return axios.put(`${baseUrl}${url}`,params).then((data)=>data)
}

export const DELETE=(url,params)=>{
  axios.defaults.headers.common['authorization'] = 'Bearer '+localStorage.getItem('token')
  return axios.delete(`${baseUrl}${url}`,params).then((data)=>data)
}